package com.itheima.reflect;

import java.lang.reflect.Field;

public class ReflactDemo4 {
    public static void main(String[] args) throws NoSuchFieldException, IllegalAccessException {
        Class c = Student.class;
        Field[] f = c.getDeclaredFields();
        for (Field field : f) {
            System.out.println(field);
        }
        Student s = new Student("zhangsan",23);

        Field age = c.getDeclaredField("age");
        age.setAccessible(true);

        Object o = age.get(s);
        System.out.println(o);

        age.set(s,18);

        System.out.println(s);
    }
}
